﻿<UserControl x:Class="JenkinsController.View.Controls.JobStatusFilterControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:controls="clr-namespace:JenkinsController.View.Controls"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
    <ItemsControl ItemsSource="{Binding AvailableJobStatuses}">
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <StackPanel Orientation="Horizontal" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid Margin="5,0,0,0">
                    <controls:JobStatusControl Status="{Binding}" />
                    <Ellipse Cursor="Hand" Width="16" Height="16">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MouseLeftButtonDown">
                                <i:InvokeCommandAction
                                    Command="{Binding Command, RelativeSource={RelativeSource FindAncestor, AncestorType=UserControl}}"
                                    CommandParameter="{Binding}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                        <Ellipse.Style>
                            <Style TargetType="Ellipse">
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Fill" Value="Transparent" />
                                    </Trigger>
                                    <DataTrigger Value="True">
                                        <DataTrigger.Binding>
                                            <MultiBinding Converter="{StaticResource ObjectsEqualsConverter}">
                                                <Binding />
                                                <Binding Path="SelectedJobStatus"
                                                         RelativeSource="{RelativeSource FindAncestor, AncestorType=UserControl}" />
                                            </MultiBinding>
                                        </DataTrigger.Binding>
                                        <Setter Property="Fill" Value="Transparent" />
                                    </DataTrigger>
                                </Style.Triggers>
                                <Setter Property="Fill" Value="#A0FFFFFF" />
                            </Style>
                        </Ellipse.Style>
                    </Ellipse>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</UserControl>